package com.example.analysis.controller;

import com.example.analysis.exception.BusinessException;
import com.example.analysis.utils.Response;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class ExceptionHandlerController {
    @ExceptionHandler(BusinessException.class)
    public Response<String> handleException(BusinessException e) {
        System.out.println(e.getMessage());
        return new Response<>(true, e.getMessage(), null, e.getCode());
    }

    @ExceptionHandler(Exception.class)
    public Response<String> handleException(Exception e) {
        System.out.println(e.getMessage());
        return new Response<>(true, e.getMessage(), null, 500);
    }
}
